home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group95b.txt / 000042_icon-group-sender _Fri Jun 16 10:51:39 1995.msg < prev    next >
Internet Message Format  |  1995-09-18  |  3KB

  1. Received: by cheltenham.cs.arizona.edu; Fri, 16 Jun 1995 12:29:08 MST
  2. Message-Id: <v01520d03ac076c61d971@[199.35.110.124]>
  3. Mime-Version: 1.0
  4. Content-Type: text/plain; charset="us-ascii"
  5. Date: Fri, 16 Jun 1995 10:51:39 -0800
  6. To: icon-group@cs.arizona.edu
  7. From: bobalex@netcom.com (Bob Alexander)
  8. Subject: Re: Best and worst features of Icon (was: ICON vs Ted Nelson)
  9. Errors-To: icon-group-errors@cs.arizona.edu
  10.  
  11. >From: scott@cs.arizona.edu (Scott E Gilbert)
  12. >Personally, I'd like to see the &null value act as a general purpose
  13. >identity for all of the operators except when used as a procedure call. For
  14. >example:
  15. >
  16. >  1 + &null           -> 1
  17. >  1 * &null           -> 0
  18. >  'abc' ++ &null      -> 'abc'
  19. >  "foo" || &null      -> "foo"
  20. >  [1,2,3] ||| &null   -> [1,2,3]
  21. >  &null(1, 2, 3)      -> Obscure Runtime Error: 169
  22. >
  23. >I'd probably even extend this to other "operators" such as those that work
  24. >on lists, tables and sets.
  25.  
  26. Interestingly, the behavior you suggest was present in SNOBOL4, Icon's
  27. grandparent.  I'd bet the reason for the absense of default behaviors for
  28. &null is that those behaviors can be the source of obscure bugs.  I know I
  29. personally catch lots of errors when I try to add a number to a variable
  30. that doesn't exist (i.e. was misspelled) -- usually my first seven errors
  31. in any new program!
  32.  
  33. Another argument for no default behaviors:  a program is more transparent
  34. (in a readability sense) if the expected initial value of a variable is
  35. explicitly set -- if it isn't you might have to scan back in a procedure to
  36. make sure it didn't have some value left from a previous use.  This can
  37. bite you for "static" variables, too.
  38.  
  39. On the other hand, since &null is the often-used equivalent of boolean
  40. "false", it *does* have a default behavior for that usage.
  41.  
  42. Bottom line:  although sometimes I wish for the cuteness of not having to
  43. initialize a variable before I use it, I tend to prefer the existing
  44. handling of &null.  I'm willing to put in the extra line of code (which
  45. makes my program more readable), and bear the extra millisecond and few
  46. bytes added to my program.
  47.  
  48. What I *do* wish for sometimes, though, is a generic non-null value, to
  49. provide symmetry for boolean usage -- something like &true (although using
  50. 1 or "true" isn't really all that bad).
  51.  
  52. My biggest Icon wish:  better connection with the real world (i.e.
  53. interface to C -- this is probably Icon's worst handicap).
  54.  
  55. By the way, the preferred spelling is "Icon", not "ICON" (as pointed out in
  56. the FAQ).
  57.  
  58. Bob Alexander
  59. bobalex@netcom.com
  60.  
  61.  
  62.